import { Injectable } from '@nestjs/common';
import { InjectEntityManager } from '@nestjs/typeorm';
import { EntityManager } from 'typeorm';
import { RrzArticleNodes } from '../entity/rrz_article_nodes.entity';

@Injectable()
export class AudioCateService {
  constructor(
    @InjectEntityManager()
    private readonly entityManager: EntityManager,
  ) {}

  async getAudioCateListById(id: any): Promise<RrzArticleNodes[]> {
    const qb = this.entityManager
      .createQueryBuilder(RrzArticleNodes, 'articleCate')
      .select(['articleCate.id', 'articleCate.name', 'articleCate.img'])
      .where('parent_id = :parent_id', { parent_id: id });
    const cate = qb.getMany();
    return await cate;
  }
}
